#!/usr/bin/python3
import tushare as ts
print(ts.__version__)
#ts.set_token('dfeb543866c1b2b3e804f3cbed560e9e1709b0d06cd8182e1cc5676d')
ts_pro = ts.pro_api('ea3263c5424f08c3e04d605af9458cfc349613d5b7c27e99994eb396')
df = ts_pro.fund_basic(market = 'E')
print(df.to_json(orient='records', lines=True))

df = ts_pro.fund_company()
print(df)
df = ts_pro.fund_nav(ts_code= '159809.SZ', market=  'E')
print(df)
df = ts_pro.fund_daily(ts_code= '159809.SZ', start_date= '20200525', end_date='20211231')
print(df)


#curl --request POST http://localhost:9200/fund_basic/_doc/TVFrgnIBzY05muk4f-u5?pretty=true --header "Content-Type: application/json" --data $'{"ts_code":"515190.SH","name":"中银证券500ETF","management":"中银证券","custodian":"招商银行","fund_type":"股票型","found_date":"20200430","due_date":null, "list_date": "20200527", "issue_date": "20200330", "delist_date": null, "issue_amount":2.5147, "m_fee":0.15, "c_fee":0.05, "duration_year":null, "p_value":1.0, "min_amount":0.100, "exp_return":null, "benchmark":"中证500指数收益率", "status":"I", "invest_type":"被动指数型","type":"契约型开放式","trustee":null, "purc_startdate":"20200527", "redm_startdate":"20200527","market":"E"}'